
/*
 * =====================================================================================
 *
 *       Filename:  RequestSession.h
 *
 *    Description:
 *
 *
 *        Version:  1.0
 *        Created:  03/06/19 15:59:09
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  liushuyong (), shuyong1999@163.com
 *        Company:  shuyong
 *
 * =====================================================================================
 */

#ifndef __RequestSession_H__
#define __RequestSession_H__

#include <string>
#include <sstream>
#include <iostream>
#include <map>
//#include "tts_engine_c_api.h"
//#include "tts_api.h"
#include "Lock.h"
#include "HttpParam.h"
#include "CommHead.h"
#include "RPCContext.h"
#include "TTSEngineMgr.h"
#include "DebugInfo.h"

using brpc::Controller;
using std::string;
using std::atomic;
using std::shared_ptr;
using brpc::ClosureGuard;
using google::protobuf::Closure;
using std::stringstream;
using std::ostream_iterator;
using std::nothrow;
using std::ostringstream;
using std::map;
using std::make_shared;

class RequestSession {
  public:
    RequestSession(double engineParam[], bool isAll);
    virtual ~ RequestSession();

    void doSynthetize(RPCContextSPtr& rpcCtx);
    void readCache(RPCContextSPtr& rpcCtx);
    void setContextInfo(RPCContextSPtr& rpcCtx);

  private:

  public:
    TTSEngineMgrSPtr mspTTSEngineMgr;
    DebugInfo mDebugInfo;
    atomic < int32_t > mlastSeq;    // session err_no;

  private:
    TTSEngineParam mTTSEngineParam; // TTSEngine param

    //add by shuyong 2019-11-22 for  SSML
    string _timestamp;  // current timestamp
    string _time_cost_detail;
    int _retry_times;
};
typedef shared_ptr < RequestSession > RequestSessionSPtr;

#endif
